package cn.dgut.training.service.impl;


import cn.dgut.training.entity.activity.GroupBuying;
import cn.dgut.training.entity.dto.GroupJoinDTO;
import cn.dgut.training.entity.transaction.GroupJoin;
import cn.dgut.training.entity.vo.GroupJoinVO;
import cn.dgut.training.mapper.GroupJoinMapper;
import cn.dgut.training.service.IGroupJoinService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class GroupJoinServiceImpl extends ServiceImpl<GroupJoinMapper, GroupJoin> implements IGroupJoinService {

    @Resource
    private GroupJoinMapper groupJoinMapper;

    @Override
    public GroupJoinVO listJoinByPage(GroupJoinDTO groupJoinDTO) {
        //构造分页
        IPage ipage = new Page();
        BeanUtils.copyProperties(groupJoinDTO, ipage);
        //获取条件查询构造器
        QueryWrapper queryWrapper = groupJoinDTO.getWrapper(groupJoinDTO);

        IPage res = groupJoinMapper.selectPage(ipage, queryWrapper);

        GroupJoinVO groupJoinVO = new GroupJoinVO(res);

        return groupJoinVO;
    }
}
